package com.concurrency.example.proxy;

import com.concurrency.example.proxy.cglibDemo.CglibFactory;
import com.concurrency.example.proxy.sdkDemo.ProxyFactory;
import com.concurrency.example.proxy.staticDemo.ProxyPoint;
import org.junit.Test;

public class MyTest {
    // 静态代理测试方法
    @Test
    public void fun1(){
        ProxyPoint proxyPoint = new ProxyPoint();
        proxyPoint.sell();
    }

    // JDK动态代理测试
    @Test
    public void fun2() throws InterruptedException {
        ProxyFactory proxyFactory = new ProxyFactory();
        SellTickets sellTickets = proxyFactory.getSellTickets();
        sellTickets.sell();

        System.out.println(sellTickets.getClass());
        while (true){
            Thread.sleep(1000);
        }
    }

    // Cglib动态代理测试类
    @Test
    public void fun3(){
        CglibFactory cglibFactory = new CglibFactory();
        TrainStation trainStation = cglibFactory.getProxy();
        trainStation.sell();
    }
}
